public class Test03 {
    public static void main(String[] args) {
        int[][] nums = {
                {1, 2, 8, 9},
                {2, 4, 9, 12},
                {4, 7, 10, 13},
                {6, 8, 11, 15}
        };
        System.out.println(find(nums,7));
    }
    public static boolean find(int[][] nums,int number){
        if(nums == null || nums.length == 0|| nums[0].length == 0){
            return false;
        }
        int rows = nums.length;
        int cols = nums[0].length;
        int row = 0;//起始行坐标
        int col = cols-1;//起始列坐标

        while(row>=0 && row<rows && col >= 0 && col <cols){
            if(nums[row][col] == number) return true;
            else if(nums[row][col] > number) col --;
            else row++;
        }
        return false;
    }
}
